/**
/* Copyright (C) 2011, Catdroid, Jordi Bernabeu
/* 
/* This program is free software; you can redistribute it and/or
/* modify it under the terms of the GNU General Public License
/* as published by the Free Software Foundation in its version 2
/* of the License.
/* 
/* This program is distributed in the hope that it will be useful,
/* but WITHOUT ANY WARRANTY; without even the implied warranty of
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
/* GNU General Public License for more details.
/*
/* You should have received a copy of the GNU General Public License
/* along with this program; if not, write to the Free Software
/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
/* 
/* @author Jordi Bernabeu (@androideverde)
 */

package org.catdroid.demolife;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

/**
 * /* Second activity that is called from mainActivity.
 */
public class AnotherActivity extends Activity {

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.another);

		// Establim un Listener per capturar l'event onClick sobre el botó Go
		Button btnGo = (Button) findViewById(R.id.btnGo);
		btnGo.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// Canviem el text de txtTarget pel contingut de edtField
				TextView t = (TextView) findViewById(R.id.txtTarget);
				EditText e = (EditText) findViewById(R.id.edtField);
				t.setText(e.getText());
			}
		});

		// Establim un Listener per capturar l'event onClick sobre el botó Share
		Button btnShare = (Button) findViewById(R.id.btnShare);
		btnShare.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// Llencem un intent per compartir el text escrit al TextView
				EditText e = (EditText) findViewById(R.id.edtField);
				Intent i = new Intent(Intent.ACTION_SEND);
				i.setType("text/plain");
				i.putExtra(Intent.EXTRA_TEXT, e.getText());
				startActivity(i);
				// startActivity(Intent.createChooser(i,
				// "Place share dialog title here"));
			}
		});

	}
}
